package com.fr.base;

import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.chart.core.ChartUtils;
import java.awt.Color;
import java.awt.Font;
import java.io.InvalidObjectException;
import java.util.Map;
import java.util.WeakHashMap;

public class FRFont extends Font
  implements Cloneable
{
  private static final long serialVersionUID = -4341538101804628719L;
  private static final String DEFAULT_FONTNAME = "SimSun";
  private static Map initializeFRFont = new WeakHashMap();
  private Color foreground = Color.black;
  private byte underline = 0;
  private boolean strikethrough = false;
  private boolean shadow = false;
  private boolean superscript = false;
  private boolean subscript = false;

  public static FRFont getInstance()
  {
    return getInstance("SimSun", 0, 12);
  }

  public static FRFont getInstance(Font paramFont)
  {
    return getInstance(paramFont.getName(), paramFont.getStyle(), paramFont.getSize());
  }

  public static FRFont getInstance(String paramString, int paramInt1, int paramInt2)
  {
    return getInstance(paramString, paramInt1, paramInt2, Color.black, 0, false, false, false, false);
  }

  public static FRFont getInstance(String paramString, int paramInt1, int paramInt2, Color paramColor)
  {
    return getInstance(paramString, paramInt1, paramInt2, paramColor, 0, false, false, false, false);
  }

  public static FRFont getInstance(String paramString, int paramInt1, int paramInt2, Color paramColor, int paramInt3)
  {
    return getInstance(paramString, paramInt1, paramInt2, paramColor, paramInt3, false, false, false, false);
  }

  public static FRFont getInstance(String paramString, int paramInt1, int paramInt2, Color paramColor, int paramInt3, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4)
  {
    FK localFK = new FK(paramString, paramInt1, paramInt2, paramColor, paramInt3, paramBoolean1, paramBoolean2, paramBoolean3, paramBoolean4);
    Object localObject = initializeFRFont.get(localFK);
    if (localObject != null)
      return ((FRFont)localObject);
    FRFont localFRFont = new FRFont(paramString, paramInt1, paramInt2, paramColor, paramInt3, paramBoolean1, paramBoolean2, paramBoolean3, paramBoolean4);
    initializeFRFont.put(localFK, localFRFont);
    return localFRFont;
  }

  private FRFont(String paramString, int paramInt1, int paramInt2, Color paramColor, int paramInt3, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4)
  {
    super(paramString, paramInt1, paramInt2);
    this.foreground = paramColor;
    this.underline = (byte)paramInt3;
    this.strikethrough = paramBoolean1;
    this.shadow = paramBoolean2;
    this.superscript = paramBoolean3;
    this.subscript = paramBoolean4;
  }

  public String getStyleName()
  {
    int i = getStyle();
    if (i == 1)
      return Inter.getLocText("FRFont-bold");
    if (i == 2)
      return Inter.getLocText("FRFont-italic");
    if (i == 3)
      return Inter.getLocText("FRFont-bolditalic");
    return Inter.getLocText("FRFont-plain");
  }

  public FRFont applyName(String paramString)
  {
    return getInstance(paramString, this.style, this.size, this.foreground, this.underline, this.strikethrough, this.shadow, this.superscript, this.subscript);
  }

  public FRFont applyStyle(int paramInt)
  {
    return getInstance(this.name, paramInt, this.size, this.foreground, this.underline, this.strikethrough, this.shadow, this.superscript, this.subscript);
  }

  public FRFont applySize(int paramInt)
  {
    return getInstance(this.name, this.style, paramInt, this.foreground, this.underline, this.strikethrough, this.shadow, this.superscript, this.subscript);
  }

  public FRFont applyForeground(Color paramColor)
  {
    return getInstance(this.name, this.style, this.size, paramColor, this.underline, this.strikethrough, this.shadow, this.superscript, this.subscript);
  }

  public FRFont applyUnderline(int paramInt)
  {
    return getInstance(this.name, this.style, this.size, this.foreground, paramInt, this.strikethrough, this.shadow, this.superscript, this.subscript);
  }

  public FRFont applyStrikethrough(boolean paramBoolean)
  {
    return getInstance(this.name, this.style, this.size, this.foreground, this.underline, paramBoolean, this.shadow, this.superscript, this.subscript);
  }

  public FRFont applyShadow(boolean paramBoolean)
  {
    return getInstance(this.name, this.style, this.size, this.foreground, this.underline, this.strikethrough, paramBoolean, this.superscript, this.subscript);
  }

  public FRFont applySuperscript(boolean paramBoolean)
  {
    return getInstance(this.name, this.style, this.size, this.foreground, this.underline, this.strikethrough, this.shadow, paramBoolean, this.subscript);
  }

  public FRFont applySubscript(boolean paramBoolean)
  {
    return getInstance(this.name, this.style, this.size, this.foreground, this.underline, this.strikethrough, this.shadow, this.superscript, paramBoolean);
  }

  public Color getForeground()
  {
    return this.foreground;
  }

  public int getUnderline()
  {
    return this.underline;
  }

  public boolean isStrikethrough()
  {
    return this.strikethrough;
  }

  public boolean isShadow()
  {
    return this.shadow;
  }

  public boolean isSuperscript()
  {
    return this.superscript;
  }

  public boolean isSubscript()
  {
    return this.subscript;
  }

  public int hashCode()
  {
    int i = super.hashCode();
    if (this.foreground != null)
      i += this.foreground.hashCode();
    return i;
  }

  public boolean equals(Object paramObject)
  {
    if (paramObject == this)
      return true;
    if ((paramObject == null) || (!(paramObject instanceof FRFont)))
      return false;
    FRFont localFRFont = (FRFont)paramObject;
    return ((super.equals(paramObject)) && (ComparatorUtils.equals(localFRFont.getForeground(), getForeground())) && (localFRFont.getUnderline() == getUnderline()) && (localFRFont.isStrikethrough() == isStrikethrough()) && (localFRFont.isShadow() == isShadow()) && (localFRFont.isSuperscript() == isSuperscript()) && (localFRFont.isSubscript() == isSubscript()));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return this;
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    localJSONObject.put("color", ChartUtils.color2JS(getForeground()));
    localJSONObject.put("size", getSize());
    localJSONObject.put("fontName", getName());
    localJSONObject.put("style", ChartUtils.fontStyle2JS(getStyle()));
    return localJSONObject;
  }

  protected Object readResolve()
    throws InvalidObjectException
  {
    if (getClass() != FRFont.class)
      throw new InvalidObjectException("subclass didn't correctly implement readResolve");
    FK localFK = new FK(this);
    Object localObject = initializeFRFont.get(localFK);
    if (localObject == null)
    {
      localObject = this;
      initializeFRFont.put(localFK, localObject);
    }
    return localObject;
  }

  static String access$000(FRFont paramFRFont)
  {
    return paramFRFont.name;
  }

  static int access$100(FRFont paramFRFont)
  {
    return paramFRFont.style;
  }

  static int access$200(FRFont paramFRFont)
  {
    return paramFRFont.size;
  }

  static Color access$300(FRFont paramFRFont)
  {
    return paramFRFont.foreground;
  }

  static byte access$400(FRFont paramFRFont)
  {
    return paramFRFont.underline;
  }

  static boolean access$500(FRFont paramFRFont)
  {
    return paramFRFont.strikethrough;
  }

  static boolean access$600(FRFont paramFRFont)
  {
    return paramFRFont.shadow;
  }

  static boolean access$700(FRFont paramFRFont)
  {
    return paramFRFont.superscript;
  }

  static boolean access$800(FRFont paramFRFont)
  {
    return paramFRFont.subscript;
  }

  private static class FK
  {
    String name;
    int style;
    int size;
    Color foreground;
    int underline;
    boolean strikethrough;
    boolean shadow;
    boolean superscript;
    boolean subscript;

    FK(FRFont paramFRFont)
    {
      this(FRFont.access$000(paramFRFont), FRFont.access$100(paramFRFont), FRFont.access$200(paramFRFont), FRFont.access$300(paramFRFont), FRFont.access$400(paramFRFont), FRFont.access$500(paramFRFont), FRFont.access$600(paramFRFont), FRFont.access$700(paramFRFont), FRFont.access$800(paramFRFont));
    }

    FK(String paramString, int paramInt1, int paramInt2, Color paramColor, int paramInt3, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4)
    {
      this.name = paramString;
      this.style = paramInt1;
      this.size = paramInt2;
      this.foreground = paramColor;
      this.underline = paramInt3;
      this.strikethrough = paramBoolean1;
      this.shadow = paramBoolean2;
      this.superscript = paramBoolean3;
      this.subscript = paramBoolean4;
    }

    public int hashCode()
    {
      return (((this.name != null) ? this.name.hashCode() : 0) ^ this.style ^ this.size ^ ((this.foreground != null) ? this.foreground.hashCode() : 0));
    }

    public boolean equals(Object paramObject)
    {
      if (paramObject == this)
        return true;
      if (!(paramObject instanceof FK))
        return false;
      FK localFK = (FK)paramObject;
      if (((this.name == null) && (localFK.name != null)) || ((localFK.name == null) && (this.name != null)))
        return false;
      return ((this.name.equals(localFK.name)) && (this.style == localFK.style) && (this.size == localFK.size) && (ComparatorUtils.equals(this.foreground, localFK.foreground)) && (this.underline == localFK.underline) && (this.strikethrough == localFK.strikethrough) && (this.shadow == localFK.shadow) && (this.superscript == localFK.superscript) && (this.subscript == localFK.subscript));
    }
  }
}